package cn.fzm.ssm.dao;

import cn.fzm.ssm.domain.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Dremeue
 * @create 2019/10/11 12:58
 **/
public interface IOrdersDao {

    @Select("select * from orders")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "orderNum", property = "orderNum"),
            @Result(column = "orderTime", property = "orderTime"),
            @Result(column = "orderStatus", property = "orderStatus"),
            @Result(column = "peopleCount", property = "peopleCount"),
            @Result(column = "payType", property = "payType"),
            @Result(column = "orderDesc", property = "orderDesc"),
            @Result(column = "productId", property = "product", one = @One(select = "cn.fzm.ssm.dao.IProductDao.findById")),

    })
    public List<Orders> findAll();

    @Select("select * from orders where id = #{id}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "orderNum", property = "orderNum"),
            @Result(column = "orderTime", property = "orderTime"),
            @Result(column = "orderStatus", property = "orderStatus"),
            @Result(column = "peopleCount", property = "peopleCount"),
            @Result(column = "payType", property = "payType"),
            @Result(column = "orderDesc", property = "orderDesc"),
            @Result(column = "productId", property = "product", one = @One(select = "cn.fzm.ssm.dao.IProductDao.findById")),
            @Result(column = "memberId", property = "member", one = @One(select = "cn.fzm.ssm.dao.IMemberDao.findById")),
            @Result(column = "id", property = "travellers", many = @Many(select = "cn.fzm.ssm.dao.ITravellerDao.findByOrdersId")),
    })
    public Orders findById(String id);
}
